
var arvalBoxesSelector = '.offerbox, .offerbox-ask';
var arvalBOClass = 'opened';

var arvalBoxes;
var arvalBoxesA;
var arvalMoreInfos;

$(document).ready(function(){
	arvalBoxesSelector 
	arvalBoxes = $(arvalBoxesSelector);
	arvalBoxesA = arvalBoxes.find('.openbox');
	arvalMoreInfos = $('.offers-moreinfo > div');

	arvalBoxesARadio = arvalBoxes.find('.selectbox');
	arvalBoxesARadio.click(function(){
		$(this).parent().find('input:radio').click();
	})

	arvalBoxesA.click( function(){
		var b = $(this).parents(arvalBoxesSelector);
		var bmi = b.attr('data-box');
		var mi = arvalMoreInfos.filter('#'+bmi);

		if(!b.hasClass(arvalBOClass)){
			arvalBoxes.removeClass(arvalBOClass)
			arvalBoxes.find('.details').text('Dettagli')
			arvalMoreInfos.hide();
			b.addClass(arvalBOClass);
			b.find('.details').text('Nascondi')
			mi.show();
		}else{
			b.removeClass(arvalBOClass);
			b.find('.details').text('Dettagli')
			mi.hide();
		}
	})

/*
	var ppssarvalform = $('#form_103_DEM_PMIit');
	ppssarvalform.attr("action","index.html");
	function ppss_validator(){
		var res = v.exec();
		if (res){
			var txt = ppssarvalform.find("textarea[name=lead_messaggio]").val();
			var val = $('#radiochk input[name="reply[promo]"]:checked').val();
			if (val===undefined){val = "non selezionato";}
			ppssarvalform.find("textarea[name=lead_messaggio]").val("opzione selezionata="+val+"<br/>-----<br/>"+txt);
		}
		return res;
	}
	ppssarvalform.attr("onsubmit","return ppss_validator()");
	ppssarvalform.find('td:first').css('width', '30%');
	ppssarvalform.find('tr.bg_linea:last').addClass('last')
	*/
})
